package convertor

import (
	"mine-info-server/domain/common-context/model/blessing-word-aggregate/aggregate"
	"mine-info-server/infra/database/mysql/common-context/blessing-word/po"
)

/*
   @author:zhongyang
   @date:2023/4/12
   @description:鸡汤文案-PO和DO的转换器
*/

type Option func(aggregate *aggregate.BlessingWordAggregate)

type BlessingWordConvertor struct {
}

func (b *BlessingWordConvertor) CreateAggregateByOption(opts ...Option) *aggregate.BlessingWordAggregate {
	res := &aggregate.BlessingWordAggregate{}
	for _, opt := range opts {
		opt(res)
	}
	return res
}

func WithBlessingWordPO(req *po.BlessingWord) Option {
	return func(aggregate *aggregate.BlessingWordAggregate) {
		if req == nil {
			return
		}
		aggregate.ID = req.ID
		aggregate.Content = req.Content
	}
}
